// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sysin

import (
	"context"
	"hotgo/internal/consts"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"
	"hotgo/utility/validate"

	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

// ActivityUpdateFields 修改活动管理字段过滤
type ActivityUpdateFields struct {
	Title     string      `json:"title"     dc:"活动名称"`
	CoverImg  string      `json:"coverImg"  dc:"封面图"`
	LunboImg  string      `json:"lunboImg"  dc:"轮播图"`
	StartAt   *gtime.Time `json:"startAt"   dc:"开始时间"`
	EndAt     *gtime.Time `json:"endAt"     dc:"结束时间"`
	Streaming string      `json:"streaming" dc:"直播流地址"`
	Rule      string      `json:"rule"      dc:"规则"`
	UpStream  string      `json:"upStream"  dc:"三方推流地址"`
	Url       string      `json:"url"       dc:"播放页面地址"`
	Price     float64     `json:"price"     dc:"视频下载价格"`
	Status    int         `json:"status"    dc:"状态"`
}

// ActivityInsertFields 新增活动管理字段过滤
type ActivityInsertFields struct {
	Title     string      `json:"title"     dc:"活动名称"`
	CoverImg  string      `json:"coverImg"  dc:"封面图"`
	LunboImg  string      `json:"lunboImg"  dc:"轮播图"`
	StartAt   *gtime.Time `json:"startAt"   dc:"开始时间"`
	EndAt     *gtime.Time `json:"endAt"     dc:"结束时间"`
	Streaming string      `json:"streaming" dc:"直播流地址"`
	Rule      string      `json:"rule"      dc:"规则"`
	UpStream  string      `json:"upStream"  dc:"三方推流地址"`
	Url       string      `json:"url"       dc:"播放页面地址"`
	Price     float64     `json:"price"     dc:"视频下载价格"`
	Status    int         `json:"status"    dc:"状态"`
}

// ActivityEditInp 修改/新增活动管理
type ActivityEditInp struct {
	entity.Activity
}

func (in *ActivityEditInp) Filter(ctx context.Context) (err error) {
	// 验证活动名称
	if err := g.Validator().Rules("required").Data(in.Title).Messages("活动名称不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证开始时间
	if err := g.Validator().Rules("required").Data(in.StartAt).Messages("开始时间不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证结束时间
	if err := g.Validator().Rules("required").Data(in.EndAt).Messages("结束时间不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证视频下载价格
	if err := g.Validator().Rules("regex:(^[0-9]{1,10}$)|(^[0-9]{1,10}[\\.]{1}[0-9]{1,2}$)").Data(in.Price).Messages("视频下载价格最多允许输入10位整数及2位小数").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type ActivityEditModel struct{}

// ActivityDeleteInp 删除活动管理
type ActivityDeleteInp struct {
	Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *ActivityDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type ActivityDeleteModel struct{}

// ActivityViewInp 获取指定活动管理信息
type ActivityViewInp struct {
	Id int `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *ActivityViewInp) Filter(ctx context.Context) (err error) {
	return
}

type ActivityViewModel struct {
	entity.Activity
}

// ActivityListInp 获取活动管理列表
type ActivityListInp struct {
	form.PageReq
	Title   string      `json:"title"   dc:"活动名称"`
	StartAt *gtime.Time `json:"startAt" dc:"开始时间"`
	EndAt   *gtime.Time `json:"endAt"   dc:"结束时间"`
	Status  int         `json:"status"  dc:"状态"`
}

func (in *ActivityListInp) Filter(ctx context.Context) (err error) {
	return
}

type ActivityListModel struct {
	Id        int         `json:"id"        dc:"id"`
	Title     string      `json:"title"     dc:"活动名称"`
	CoverImg  string      `json:"coverImg"  dc:"封面图"`
	StartAt   *gtime.Time `json:"startAt"   dc:"开始时间"`
	EndAt     *gtime.Time `json:"endAt"     dc:"结束时间"`
	Streaming string      `json:"streaming" dc:"直播流地址"`
	UpStream  string      `json:"upStream"  dc:"三方推流地址"`
	Url       string      `json:"url"       dc:"播放页面地址"`
	Price     float64     `json:"price"     dc:"视频下载价格"`
	Camera1   string      `json:"camera1"   dc:"机位1"`
	Camera2   string      `json:"camera2"   dc:"机位2"`
	Camera3   string      `json:"camera3"   dc:"机位3"`
	Camera4   string      `json:"camera4"   dc:"机位4"`
	Camera5   string      `json:"camera5"   dc:"机位5"`
	Camera6   string      `json:"camera6"   dc:"机位6"`
	Camera7   string      `json:"camera7"   dc:"机位7"`
	Camera8   string      `json:"camera8"   dc:"机位8"`
	CreateAt  *gtime.Time `json:"createAt"  dc:"添加时间"`
	UpdateAt  *gtime.Time `json:"updateAt"  dc:"更新时间"`
	Status    int         `json:"status"    dc:"状态"`
}

// ActivityExportModel 导出活动管理
type ActivityExportModel struct {
	Id        int         `json:"id"        dc:"id"`
	Title     string      `json:"title"     dc:"活动名称"`
	CoverImg  string      `json:"coverImg"  dc:"封面图"`
	LunboImg  string      `json:"lunboImg"  dc:"轮播图"`
	StartAt   *gtime.Time `json:"startAt"   dc:"开始时间"`
	EndAt     *gtime.Time `json:"endAt"     dc:"结束时间"`
	Streaming string      `json:"streaming" dc:"直播流地址"`
	Rule      string      `json:"rule"      dc:"规则"`
	UpStream  string      `json:"upStream"  dc:"三方推流地址"`
	Url       string      `json:"url"       dc:"播放页面地址"`
	Price     float64     `json:"price"     dc:"视频下载价格"`
	Camera1   string      `json:"camera1"   dc:"机位1"`
	Camera2   string      `json:"camera2"   dc:"机位2"`
	Camera3   string      `json:"camera3"   dc:"机位3"`
	Camera4   string      `json:"camera4"   dc:"机位4"`
	Camera5   string      `json:"camera5"   dc:"机位5"`
	Camera6   string      `json:"camera6"   dc:"机位6"`
	Camera7   string      `json:"camera7"   dc:"机位7"`
	Camera8   string      `json:"camera8"   dc:"机位8"`
	CreateAt  *gtime.Time `json:"createAt"  dc:"添加时间"`
	UpdateAt  *gtime.Time `json:"updateAt"  dc:"更新时间"`
	Status    int         `json:"status"    dc:"状态"`
}

// ActivityStatusInp 更新活动管理状态
type ActivityStatusInp struct {
	Id     int `json:"id" v:"required#id不能为空" dc:"id"`
	Status int `json:"status" dc:"状态"`
}

func (in *ActivityStatusInp) Filter(ctx context.Context) (err error) {
	if in.Id <= 0 {
		err = gerror.New("id不能为空")
		return
	}

	if in.Status <= 0 {
		err = gerror.New("状态不能为空")
		return
	}

	if !validate.InSlice(consts.StatusSlice, in.Status) {
		err = gerror.New("状态不正确")
		return
	}
	return
}

type ActivityStatusModel struct{}